﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Http;
using Woodbase.CodeBase.UI;
using System.Configuration;
using System.Xml.Linq;

namespace WoodbaseVideoRental.Pages.Users
{
    public partial class List : WoodbaseBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (HttpClient client = new HttpClient(ConfigurationManager.AppSettings["webservicebasepath"]))
            {
                using (HttpResponseMessage msg = client.Get("Users"))
                {
                    msg.EnsureStatusIsSuccessful();
                    var content = msg.Content.ReadAsXElement();
                    if (HttpContext.Current.Request.QueryString.HasKeys())
                    {
                        content.Add(new XAttribute(HttpContext.Current.Request.QueryString.GetKey(0), HttpContext.Current.Request.QueryString.GetValues(0)[0]));
                    }
                    contentXml.DocumentContent = content.ToString();
                    contentXml.TransformSource = Server.MapPath("~/Styles/XSLT/UserDetailList.xslt");
                    contentXml.DataBind();
                }
            }
        }
    }
}